#pragma once

#include <D3D11.h>
#include <dxgi.h>

#include <Windows.h>

#include "Common.h"

namespace Display
{
	class EXPORT RenderWindow
	{
		int windowWidth;
		int windowHeight;

		HWND windowHandle;
		MSG msg;
		bool closed;
		float bgColor[4];

		//DX 

		IDXGISwapChain* swapChain;
		ID3D11Device * device;
		ID3D11DeviceContext * context;

		ID3D11RenderTargetView* rendertargetView;

		ID3D11Texture2D * depthBuffer;
		ID3D11DepthStencilView * depthView;

		ID3D11DepthStencilState * depthState;
		//----


		RenderWindow(void);
		~RenderWindow(void);


	public:
		int GetWidth();
		int GetHeight();

		static RenderWindow * Create(LPCWSTR windowCaption,int width,int height,int posX,int posY);
		static void Destroy(RenderWindow * window);

		bool IsClosed();
		void Close();

		void HandleMessages();

		void Draw();

		void SetBGColor(float red,float green,float blue);

		void BeginDraw();
		void EndDraw();

		ID3D11Device * GetDevice();
		ID3D11DeviceContext * GetContext();
	private:
		static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
		void InitD3D();
		void ReleaseD3D();
	};
}
